﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CacheDemo1.Utility
{
    /// <summary>
    /// 第三方封装的缓存
    /// </summary>
    public class CustomCache
    {
        //定义一个静态字典  用来存数据 而且不会释放。
        private static Dictionary<string, object> CustomCacheDictionary = new Dictionary<string, object>();

        public static void Add(string key, object oValue)
        {
            CustomCacheDictionary.Add(key, oValue);
        }

        public static T Get<T>(string key)
        {
            return (T)CustomCacheDictionary[key];
        }

        public static bool Exists(string key)
        {
            return CustomCacheDictionary.ContainsKey(key);
        }

        public static void Remove(string key)
        {
            CustomCacheDictionary.Remove(key);
        }
    }
}
